package parse;

import RecordManagement.*;
import SystemManagement.*;
import PagedFile.*;

public class CreateTable extends SQL{
	public TableName table_name;
	public Attribute_list schema;
	public Attribute_list key = null;
	public Attribute_list foreign_key = null;
	public String foreign_rel = null;
	public Attribute_list foreign_attr = null;
	
	public CreateTable(String table_name, Attribute_list sch){
		this.table_name = new TableName(table_name);
		this.schema = sch;
	}
	
	public CreateTable(String table_name, Attribute_list sch, Attribute_list key){
		this.table_name = new TableName(table_name);
		this.schema = sch;
		this.key = key;
	}
	
	public CreateTable(String table_name, Attribute_list sch, Attribute_list key, String foreign_rel, Attribute_list foreign_attr){
		this.table_name = new TableName(table_name);
		this.schema = sch;
		this.foreign_attr = foreign_attr;
		this.foreign_key = key;
		this.foreign_rel = foreign_rel;
	}
	
	public TableName GetTableName(){
		return this.table_name;
	}
	
	public Attribute_list GetTableSchema(){
		return this.schema;
	}
	
	public void CrtTable(SM_Manager sm){
		try{
			sm.CreateTable(table_name.GetTableName(), schema, key, foreign_key, foreign_rel, foreign_attr);
		}
		catch(Error e){
			throw e;
		}
	}
}